<!DOCTYPE html>
<html>
<!--Made By kailuosoft.com, TEL 171 9992 9517 -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>凯络科技后台管理系统 - 订单明细</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

     <link rel="shortcut icon" href="favicon.ico"> <link href="__PUBLIC__/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/css/animate.min.css" rel="stylesheet">
    <link href="__PUBLIC__/css/style.min862f.css?v=4.1.0" rel="stylesheet">
	<link href="__PUBLIC__/css/page.css" rel="stylesheet">
    <link href="__PUBLIC__/css/new.css" rel="stylesheet">
	<script src="__PUBLIC__/js/jquery.min63b9.js?v=2.1.4"></script>
    <script src="__PUBLIC__/js/plugins/layer/layer.min.js"></script>
	<script>
		$(document).ready(function(){
			$('.cost_edit').dblclick(function(){
			name=$(this).attr('nameval');
			nval=$(this).text();
			id=$(this).parent().find('.id').val();
			$(this).parent().find('.id').attr('name','id');
			$(this).html("<input type='text' name='"+name+"' value='"+nval+"' class='input-sm form-control' class='nameedit'>");
			$(this).children().focus().val(nval);
			sku = $(this).parent()siblings().find('.sku').val();
			$(this).children().blur(function(event){
				value=$(this).val();console.log(id);console.log(sku);console.log(nval);
					$.ajax({
						url:"{:U('cost_edit')}", 
						data:'name='+name+'&value='+value+'&id='+id,
						type:"post",
						success:function(msg){	
							 if(msg=='success')
							 {   
								 $(this).val(value);
							 }
							 else
							 {
								 $(this).val(nval);
							 }
						 }
					})
					
						$a = $(this).parent().html($(this).val());
					$(this).remove();
		
				}) 
				
				
		    }) 
		}) 

	</script>
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                           <h5>采购明细</h5>
                    </div>
                    
                    <div class="ibox-content">
                    <form action="" method="post">
                    	 <input type='hidden'  name="edit" value="1"> 
                    <div style="margin-left:15px;">
                    	<input type="button" value="一键填满" class="btn btn-sm btn-primary add" id="full_in"></input>
                        <input type="hidden" value="{$porder_number}" class="btn btn-sm btn-primary add" id="porder_number"></input>
                    </div>
                    
                    
                            <div class="col-sm-10"> 
                            	<div style=" height:100%;width:1600px; overflow:auto; margin-bottom:20px;">
                                <table class="table table-bordered table-striped table-hover" style="width:100%">
                                    <thead >
                                        <tr>
                                        	<th class="sort-column name">采购员</th>
                                        	<th class="sort-column name">供应商</th>
                                            <th class="sort-column name">SKU</th>
                                            <th class="sort-column name">产品图片</th>
                                            <th class="sort-column name" width="100px">采购单价</th>
                                            <th class="sort-column name">总数量</th>
                                            <th class="sort-column name">业务员</th>
                                            <th class="sort-column name">订单号</th>
                                            <th class="sort-column name">产品数量</th>
                                            <th class="sort-column name">历史订单</th>
                                            <th class="sort-column name" width="60px">采购数量</th>
                                            <th class="sort-column name">备注</th>
                                        </tr>
                                    </thead>
                                    <tbody id='tab'>
                                    <foreach name="order_list" item="order" key="k">
                                        <tr>
                                        	<td class="buyer">
                                                {$order.buyer}
                                            </td>
                                        	<td>{$order.supplier}</td>
                                            <td class="sku"><?php echo trim($order['sku']); ?></td>
                                            <td width="150px" height="150px" ><img src="__PUBLIC__/images/{$order.sku}/{$order.main_pic}" width="100%" height="100%" alt="图片不存在或已丢失" /></td>
                                            <td class="cost_edit" nameval='cost_price' name="cost_price">{$order.cost_price}</td>
                                            <!--<td nameval='quantity' id = "count">{$order.count}</td>-->
                                            <td>{$order.count}</td>
                                            <td>{$order.salesman}</td>
                                            <td>{$order.order_number}</td>
                                            <td class='quantity_{$k}'>{$order['quantity']-$order['cumulative_quantity']}</td>
                                            <td><if condition="($order.order_date gt $now_end) OR ($order.order_date lt $now_start)">**</if></td>
                                            <td><input type='text' class='input-sm form-control' name='purchase_quantity[]' id="tity_{$k}" value="<if condition='$order.order_number neq null'>{$order.purchase_quantity}</if>">
<input type='text' class='input-sm form-control' style="text-align:center;display:none;" name='cost_sku[]'  value="<?php echo trim($order['sku']); ?>">
                                            </td>
                                            <td>
                                            	
                                                <input type='text' class='input-sm form-control' name='remarks[]' value="{$order.remarks}">

                                            	<input type='text' class='id'  value="{$order.id}">
												<input type='text' class='sku'  value="{$order.sku}">
                                            </td>
                                       </tr>
                                  </foreach>
                                 
				<tr>
  
                                       		<td colspan="12">
                                            	<input type="submit" class="btn btn-lg btn-primary sku" value="保存" ></input>
                                                
                                            </td>
                                       </tr>
                                       
                                </table>
                                </div>  
                        	</div>
                            
                       </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="__PUBLIC__/js/jquery.min63b9.js?v=2.1.4"></script>
	<script src="__PUBLIC__/js/bootstrap.min14ed.js?v=3.3.6"></script>
    <script src="__PUBLIC__/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="__PUBLIC__/js/content.mine209.js?v=1.0.0"></script>
    <script src="__PUBLIC__/js/plugins/iCheck/icheck.min.js"></script>
    <script src="__PUBLIC__/js/demo/peity-demo.min.js"></script>
    
    <script src="__PUBLIC__/js/plugins/layer/laydate/laydate.js"></script>
    <script src="__PUBLIC__/js/plugins/jquery.tablesort.min.js"></script>
   


</body>
<!--Made By kailuosoft.com, TEL 171 9992 9517 -->
<script  type="text/javascript"  src="http://g.tbcdn.cn/sj/securesdk/0.0.3/securesdk_v2.js"  id="J_secure_sdk_v2" data-appkey="23416550"></script>
<script>
	$('#full_in').click(function(){
		var count = "{$k}";
		for(var i=0;i<=count;i++){
			var a = $(".quantity_"+i).text();
			var b = $('#tity_'+i).val(a);;
		}
	})

</script>
<script>
$(document).ready(function() {
	$(function(){
		 function merge2() {     //可实现合并单元格,上下行来比较 
			var totalCols = $("#tab").find("tr:eq(0)").find("td").length; 
			var totalRows = $("#tab").find("tr").length; 
			if(totalRows > 1){
				for ( var i = totalCols-1; i >= 0; i--) { 
					if(i >= 3)continue;
					var sum =0;
					for ( var j = totalRows-1; j >= 0; j--) { 
						startCell = $("#tab").find("tr").eq(j).find("td").eq(i); 
						targetCell = $("#tab").find("tr").eq(j - 1).find("td").eq(i);	
					if (startCell.text() == targetCell.text() && targetCell.text() != "") { 
						
						if(i == 2){
							var one = 	$("#tab").find("tr").eq(j).find("td").eq(2); 
							var one_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(2); 
							var two = 	$("#tab").find("tr").eq(j).find("td").eq(3); 
							var two_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(3); 
							var there = $("#tab").find("tr").eq(j).find("td").eq(4); 
							var there_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(4);
							
							var five = $("#tab").find("tr").eq(j).find("td").eq(5);
							
							var five_1 = $("#tab").find("tr").eq(j-1).find("td").eq(5); 
							var eight = $("#tab").find("tr").eq(j).find("td").eq(8); 
							var eight_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(8);
							
							if(one.html()==one_1.html()){
								sum = parseInt(eight.html())+parseInt(eight_1.html());
								$('#count').html(sum);
							}
							two_1.attr("rowSpan", (two.attr("rowSpan")==undefined)?2:(eval(two.attr("rowSpan"))+1));
							there_1.attr("rowSpan", (there.attr("rowSpan")==undefined)?2:(eval(there.attr("rowSpan"))+1));
							five_1.attr("rowSpan", (five.attr("rowSpan")==undefined)?2:(eval(five.attr("rowSpan"))+1));
							
							
							
							five.remove();
							two.remove();
							there.remove();
						}
						targetCell.attr("rowSpan", (startCell.attr("rowSpan")==undefined)?2:(eval(startCell.attr("rowSpan"))+1)); 
						startCell.remove(); 
					} 
				} 
				} 
			 } 
		 }
		 merge2();
	 })
 })


</script>

</html>
